//
//  CashbackRecordVC.m
//  NewPro
//
//  Created by 何荧红 on 2019/6/12.
//  Copyright © 2019 何荧红. All rights reserved.
//

#import "CashbackRecordVC.h"
#import "ZJScrollPageView.h"
#import "CashbackRecordFVC.h"
#import "CashbackRecordSVC.h"

@interface CashbackRecordVC ()<ZJScrollPageViewDelegate>

@property (nonatomic, strong) NSArray *titles;
@property (nonatomic, strong) NSArray *childVcs;
@property (nonatomic, strong) ZJScrollPageView *scrollPageView;

@end

@implementation CashbackRecordVC

- (void)viewDidLoad {
    [super viewDidLoad];
    [self initCSS];
}
- (void)initCSS{
    [self setNavBarWithTitle:@"调整返现记录"];
    //必要的设置, 如果没有设置可能导致内容显示不正常
    self.automaticallyAdjustsScrollViewInsets = NO;
    ZJSegmentStyle *style = [[ZJSegmentStyle alloc] init];
    //显示滚动条
    style.showLine = YES;
    // 颜色渐变
    style.gradualChangeTitleColor = YES;
    //    style.scaleTitle = YES;
    style.autoAdjustTitlesWidth = YES;
    style.titleMargin = 35;
    style.scrollLineColor = [UIColor colorWithRed:12/255.0 green:166/255.0 blue:240/255.0 alpha:1.0];
    style.normalTitleColor = [UIColor colorWithRed:153/255.0 green:153/255.0 blue:153/255.0 alpha:1.0];
    style.selectedTitleColor = [UIColor colorWithRed:12/255.0 green:166/255.0 blue:240/255.0 alpha:1.0];
    self.titles = @[@"我发起的",@"我接收的"];
    CashbackRecordFVC *FVC = [[CashbackRecordFVC alloc] init];
    CashbackRecordSVC *SVC = [[CashbackRecordSVC alloc]init];
    self.childVcs = @[FVC,SVC];
    
    // 初始化
    _scrollPageView = [[ZJScrollPageView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT) segmentStyle:style titles:self.titles parentViewController:self delegate:self];
    // 这里可以设置头部视图的属性(背景色, 圆角, 背景图片...)
    //    scrollPageView.segmentView.backgroundColor = [UIColor blackColor];
    [self.view addSubview:_scrollPageView];
}
#pragma ZJScrollPageViewDelegate 代理方法
- (NSInteger)numberOfChildViewControllers {
    return self.titles.count;
}

- (UIViewController<ZJScrollPageViewChildVcDelegate> *)childViewController:(UIViewController<ZJScrollPageViewChildVcDelegate> *)reuseViewController forIndex:(NSInteger)index {
    UIViewController<ZJScrollPageViewChildVcDelegate> *childVc = reuseViewController;
    if (!childVc && index == 0) {
        childVc = [[CashbackRecordFVC alloc] init];
    }
    if (!childVc && index == 1) {
        childVc = [[CashbackRecordSVC alloc] init];
    }
    return childVc;
}
- (BOOL)shouldAutomaticallyForwardAppearanceMethods {
    return NO;
}

@end
